$(function () {
    var temp = JSON.parse(localStorage.getItem("gameNumber"));
    //数组重组的方法
    function shuffle(a) {
        var b = [];
        while (a.length > 0){
            var index = parseInt(Math.random() * (a.length - 1));
            b.push(a[index]);
            a.splice(index, 1);
        }
        return b;
    }
    var gamers = shuffle(temp);
console.log(gamers)
    var i = 1;  //点击次数
    var j = 0;
$(".role").click(function () {
    if(i%2!==0){
        $("#picture").attr("src", "../img/yincang.png");
        $("#picture").after($("<div></div>").text(`角色：${gamers[j]}`).addClass("identity"));


       if((j+1)==gamers.length){
           if($('.role').text()=="法官查看"){
               window.location="task2-4.html"
           }
           $('.role').text("法官查看");
           return;
       }else{
           $(".role").text(`隐藏并传递给${j+2}号`);
       }

        i++;
    }else{
        $('.identity').remove();
        $("#picture").attr("src", "../img/chakan.png");
        j++;
        $(".circle").text(`${j+1}`);
        $(".role").text(`查看${j+1}号身份`);
        i++
    }

})

})